<extend name="Public/base"/>

<block name="body">
<div class="Tool_Bar" id="Model_Bar">
<dl>
	<dt>字段管理</dt>
    <if condition="Is_Auth('Admin/Model/index')">
	<dd><a href="{:U('Admin/Model/index')}"><span>模型列表</span></a></dd>
    </if>
	<dd><a class="current" href="JavaScript:void(0);" onclick="Data_Reload('ModelField_Data_List');"><span>字段列表</span></a></dd>
    <if condition="Is_Auth('Admin/ModelField/add')">
	<dd><a href="{:U('Admin/ModelField/add',array('model_id'=>I('get.model_id')))}"><span>新增</span></a></dd>
	</if>
</dl>
</div>
<table id="ModelField_Data_List"></table>
<script type="text/javascript">
$(function() {
    $("#ModelField_Data_List").datagrid({
        url: "{:U('Admin/ModelField/index')}&model_id={:I('get.model_id')}",
        fit: true,
        striped: true,
        border: false,
        pagination: false,
        sortName: 'id',
        sortOrder: 'desc',
        toolbar: '#ModelField_Bar',
        singleSelect: true,
        columns: [[{
            field: 'title',
            title: '字段标题',
            width: 100,
            sortable: true
        },
        {
            field: 'name',
            title: '字段名',
            width: 100,
            sortable: true
        },
        {
            field: 'group_id',
            title: '字段分组',
            width: 80,
            sortable: true
        },
        {
            field: 'type',
            title: '数据类型',
            width: 100,
            sortable: true
        },
        {
            field: 'remark',
            title: '备注',
            width: 100,
            sortable: true
        },
        {
            field: 'status',
            title: '状态',
            width: 100,
            sortable: true,
            formatter: function(value, row, index) {
                var op_status = new Array();
				op_status['0'] = "禁用";
                op_status['1'] = "启用";
                return op_status[value];
            }
        },
        {
            field: 'sort_l',
            title: '列表',
            width: 40,
            sortable: true
        },
        {
            field: 'sort_s',
            title: '搜索',
            width: 40,
            sortable: true
        },
        {
            field: 'sort_a',
            title: '新增',
            width: 40,
            sortable: true
        },
        {
            field: 'sort_e',
            title: '修改',
            width: 40,
            sortable: true
        },
        {
            field: 'l_width',
            title: '列表宽度',
            width: 55,
            sortable: true
        },
        {
            field: 'operate',
            title: '操作',
            width: 200,
            formatter: function(value, row, index) {
                operate_menu = '';
				
				<if condition="Is_Auth('Admin/ModelField/edit')">
				operate_menu = operate_menu+"<a href='<?php echo U('Admin/ModelField/edit'); ?>&id="+row.id+"&model_id=<?php echo I('get.model_id'); ?>' >编辑</a>";
				</if>
				
				<if condition="Is_Auth('Admin/ModelField/del')">
				operate_menu = operate_menu+" | <a href='#' onclick=Data_Ajax('<?php echo U('Admin/ModelField/del'); ?>&id="+row.id+"','ModelField_Data_List')>删除</a>";
				</if>

				return operate_menu;
			}}
		]]
	});
})
</script>
</block>
